{include file="public_head" /}
<!-- chk_3 -->
<link href="__STATIC__/css/chk_3.css" rel="stylesheet" type="text/css"/>
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">

<body class="nav-md">

<div class="container body">


    <div class="main_container">

        {include file="public_sidebar,public_nav" /}

        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">
                <div class="page-title">
                    <div class="title_left">
                        <h3>
                            优惠券管理
                        </h3>
                    </div>
                </div>
                <div class="clearfix"></div>

                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>{$mate_title}
                                </h2>
                                <a style="float: right" href="{:url('Coupon/create')}"
                                   class="btn btn-success btn-sm">创建优惠券</a>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <form name="form" id="form" method="get" action="">
                                    <div class="title_left">
                                        <div class="input-group col-md-1 col-sm-3 col-xs-4" style="float: left;margin: 0 2%;">
                                            <select name="type" class="select2_single" style="width: 100%;"
                                                    tabindex="-1">
                                                <option value="0">- 全部 -</option>
                                                <option value="1" {eq name=':input("type")' value='1' }selected{/eq}>商品优惠券</option>
                                                <option value="2" {eq name=':input("type")' value='2' }selected{/eq}>服务优惠券</option>
                                            </select>
                                        </div>

                                        <div class="col-md-2 col-sm-6 col-xs-12">
                                            <select name="single_id" class="select2_single"
                                                    tabindex="-1" style="width: 100%"
                                                    datatype="*"
                                                    nullmsg="请选择栏目分类！" errormsg="请选择栏目分类！"
                                            > <option value="0">- 全部 -</option>
                                                {volist name="single" id="item"}
                                                <option value="{$item.id}" {eq name="$item.level" value="1"}disabled{/eq}
                                                {eq name="$item.id" value=":input('single_id')"}selected{/eq}
                                                >
                                                {neq name="$item.level" value="1"}{:str_repeat('&nbsp&nbsp',$item.level)}{/neq}|{:str_repeat('--',$item.level)}{$item.cat_name}
                                                </option>
                                                {/volist}
                                            </select>
                                        </div>

                                        <div class="input-group" style="float: left;margin: 0 20px; position: relative;z-index: 10000">
                                            <input type="text" class="form-control" name="interval_timer"
                                                   id="interval_timer"
                                                   style="width: 200px;"
                                                   placeholder="请选择时间区间..." value="{:input('interval_timer')}">
                                        </div>

                                        <div class="col-md-2 col-sm-3 col-xs-3 form-group pull-left top_search">

                                            <div class="input-group">
                                                <input type="text" class="form-control" name="title"
                                                       placeholder="输入搜索内容..." value="{:input('title')}">
                                            </div>

                                        </div>
                                        <button type="submit" class="btn btn-primary" style="margin-left: 10px;">搜 索</button>
                                    </div>
                            <table class="table table-striped table-bordered">
                                <thead>
                                <tr class="success">
                                    <td>
                                        <input type="checkbox" class="checkall"
                                               onclick="CheckAll(this.checked);"/>
                                    </td>

                                    <th>优惠券ID</th>
                                    <th>优惠券分类</th>
                                    <th>发放数量</th>
                                    <th>服务分类</th>
                                    <th>优惠券标题</th>
                                    <th>使用价格</th>
                                    <th>满减价格</th>
                                    <th>开始时间 / 结束时间</th>
                                    <th width="">审核状态</th>
                                    <th width="">一级审核</th>
                                    <th width="">二级审核</th>
                                    <th width="">三级审核</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>

                                <tbody>
                                {empty name="data"}
                                <tr><td colspan="9"><div style='font-size:24px;margin:30px 0;'>没有找到记录</div></td></tr>
                                {/empty}
                                {volist name="data" id="item"}
                                <tr>
                                    <td>
                                        {neq name='item.id' value='1'}
                                        <input type="checkbox" name="id[]" value="{$item.id}"/>
                                        {/neq}
                                    </td>
                                    <td>{$item.id}</td>
                                    <td>{$item.type}</td>
                                    <td>{$item.number}</td>
                                    <td>{$item.single_id}</td>
                                    <td>{$item.title}</td>
                                    <td>{$item.actual_price} 元</td>
                                    <td>{$item.virtual_price} 元</td>
                                    <td>
                                        {neq name='item.id' value='1'}
                                        {$item.start_time|date='Y-m-d',###} 至 {$item.end_time|date='Y-m-d',###}
                                        {else/}
                                        不限制
                                        {/neq}
                                    </td>
                                    <td>{$item.auding_text}</td>
                                    <td>{$item.auding_text1}</td>
                                    <td>{$item.auding_text2}</td>
                                    <td>{$item.auding_text3}</td>
                                    <td>{$item.create_time|date='Y-m-d H:i:s',###}</td>
                                    <td class="operate">
                                        <div>

                                            <a href="{:url('MemberCoupon/index',['coupon_id'=>$item['id']])}"
                                               class="label label-info">
                                                <span class="fa fa-pencil"></span>&nbsp;&nbsp;查 看
                                            </a>
                                            {eq name="$auding_status" value="2"}
                                            <a href="{:url('Coupon/destroy', ['id' => $item['id']])}"
                                               class="label label-danger"
                                               onClick="return confirm('确定删除吗?')"
                                            >
                                                <span class="fa fa-times"></span>&nbsp;&nbsp;删 除
                                            </a>
                                            {neq name="$item.auding_status" value="2"}
                                            <a href="{:url('Coupon/update', ['id' => $item['id']])}"
                                               class="label label-primary">
                                                <span class="fa fa-pencil"></span>&nbsp;&nbsp;审核
                                            </a>
                                            {else/}
                                            <a
                                                    class="label label-warning">
                                                <span class="fa fa-pencil"></span>&nbsp;&nbsp;完 成
                                            </a>
                                            {/neq}
                                            {/eq}

                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                                <tbody align="left">
                                </tbody>
                            </table>
                            <!-- 分页 -->
                            <div style="float: right;margin-top: -30px;">{$data->render()}</div>
                                    <button type="button" class="btn btn-info" style="margin-top: 20px;" onclick="dc({:input('coupon_id')})">导出优惠券记录</button>
                            </form>
                        </div>
                    </div>
                </div>

            </div>
        </div>

    </div>
    <!-- /page content -->
</div>

</div>
</body>
{include file="public_foot" /}
<!-- public -->
<script src="__STATIC__/js/public.js"></script>
<!-- layer -->
<script src="__STATIC__/js/layer.js"></script>
<!--select-->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<script>
    function dc(){
        var title = "{:input('title')}";
        var type = "{:input('type')}";
        var single_id = "{:input('single_id')}";
        var both = "{:input('interval_timer')}";
        window.location.href = "{:url('index')}?export=123&pa=10000"+status+"&title="+title+"&type="+type+"&single_id="+single_id+'&interval_timer='+both;
    }
    // validform
    $(function () {

        // select2
        $(".select2_single").select2({
            placeholder: "请选择分类",
            allowClear: true
        });
    })
    $('#interval_timer').daterangepicker(null,
        function(start, end, label) {
//                console.log(start.toISOString(), end.toISOString(), label);
        });
</script>